package com.king.oa.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CheckLAN {

	private static final String ALLOWABLE_IP_REGEX = "(127[.]0[.]0[.]1)|" + "(localhost)|" +
	        "(10[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3})|" +
	        "(172[.]((1[6-9])|(2\\d)|(3[01]))[.]\\d{1,3}[.]\\d{1,3})|" +
	        "(192[.]168[.]\\d{1,3}[.]\\d{1,3})|(0[:]0[:]0[:]0[:]0[:]0[:]0[:]1)";
	
	private static final Pattern p = Pattern.compile(ALLOWABLE_IP_REGEX);
	
	public static boolean isLAN(String ip) {

	    Matcher matcher = p.matcher(ip);
	    return matcher.find();
		
	}
	
}
